from typing import  List

from pydantic import BaseModel, Field, ConfigDict
from datetime import datetime


class ProjectBase(BaseModel):
    name: str = Field(..., max_length=100, description="项目名称")
    description: str = Field(None, description="项目描述")


class ProjectOut(BaseModel):
    id: int
    name: str
    description: str | None = None
    owner: str
    created_at: datetime

    class Config:
        from_attributes = True  # Pydantic v2 用法，开启ORM模型支持


class ProjectOutWrapper(BaseModel):
    code: int
    message: str
    data: List[ProjectOut]
    model_config = ConfigDict(from_attributes=True)  # 允许从 ORM 对象创建
